x86/EPT: do away with hidden GUEST_TABLE_MAP_FAILED == 0 assumptions
authorJan Beulich <jbeulich@suse.com>
Mon, 3 Feb 2020 12:07:19 +0000 (13:07 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 3 Feb 2020 12:07:19 +0000 (13:07 +0100)
commit1afc776d22aac78bd0cf557aad08ac85be6617a7
tree97d3d7158585581ab431758397339609c1b34609
parent4b84622d887def7c45e130a615e702e0200745c9
x86/EPT: do away with hidden GUEST_TABLE_MAP_FAILED == 0 assumptions

The code is quite a bit easier to read and to reason about this way,
I think.

In ept_set_entry() additionally change the function's return value in
the MAP_FAILED case to -ENOMEM; -ENOENT would be applicable only when
ept_next_entry() was invoked with "read_only" set to true.

In two cases, where ept_next_level() follows an ept_split_superpage()
invocation, actually tighten the loop exit condition from
"== MAP_FAILED" to "!= NORMAL_PAGE". Continuing these loops for other
than NORMAL_PAGE is invalid, and there are ASSERT()s in place after
these loops.

Also reduce the scope of "ret" variables where possible, in particular
to better distinguish them from "rc" often used in the same function.

Finally drop pointless "else" in a few areas touched anyway.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/mm/p2m-ept.c